package com.blazer.e;

public class Person {
    //private将属性封装起来，外界不能直接调用保护了属性
    private String name;
    private int age;

    public void setName(String name) {
        this.name = name;
        System.out.println(this.name);
    }
    //无参构造 类名()
 public Person(){
    System.out.println("无参构造");
}
//有参构造 类名(参数)
public Person(String name,int age){
        this.name=name;
        this.age=age;
}
    public String getName() {

        System.out.println("123");
        return name;
    }

    public void setAge(int nianloing) {
        if(nianloing<0){
            System.out.println("不合法的值");
        }else{
            this.age = nianloing;
        }

    }

    public int getAge() {
        return age;
    }
}
